<template>
  <div class="shopcar-box">
    <div class="shopcar">
      <div class="left">
        <span>icon</span>
        <span style="font-size: 14px">联系商家</span>
      </div>
      <div class="middle" @click="show = !show">
        <div class="middle-left">
          <van-icon
            :name="x_getters_TOTAL_number?'https://s3plus.meituan.net/v1/mss_e2821d7f0cfe4ac1bf9202ecf9590e67/cdn-prod/file:9096d347/34088a7505729ed54cdfcf1ee9c3d15d.png':'https://s3plus.meituan.net/v1/mss_e2821d7f0cfe4ac1bf9202ecf9590e67/cdn-prod/file:9096d347/8f4d255dfbe4e00e7010148eb76ca753.png'"
            :badge="x_getters_TOTAL_number"
          />
        </div>
        <div class="middle-right">
          <div style="color: #fff">
            <span>￥</span>
            <span style="font-size: 20px">{{ x_getters_TOTAL_MONEY }}</span>
          </div>
          <div style="color: #888; font-size: 14px">
            另需配送费￥<span>4</span>元|支持自取
          </div>
        </div>
      </div>
      <div class="right" @click="looktotal">
        <p>去结算</p>
      </div>
    </div>
    <!-- 购物车弹出框 -->
    <van-popup
      v-model="show"
      round
      position="bottom"
      :style="{ height: '68.50%' }"
    >
      <!-- 空状态 -->
      <van-empty
        v-if="x_getters_SHOP_CAR_LIST.length === 0"
        description="描述文字"
      />
      <!-- 商品卡片 -->
      <van-card
        v-for="item in x_getters_SHOP_CAR_LIST"
        :key="item.id"
        :num="item.num"
        :price="item.price"
        :desc="item.goodsDesc"
        tag="标签"
        :title="item.name"
        :thumb="item.imgUrl"
        origin-price="10.00"
      />
    </van-popup>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";

@Component
export default class extends Vue {
  // 数据

  show: boolean = false;

  // vuex的过滤的被选中的数据
  get x_getters_SHOP_CAR_LIST(): Array<any> {
    return this.$store.getters.getters_SHOP_CAR_LIST;
  }
  // 总价
  get x_getters_TOTAL_MONEY(): number {
    return this.$store.getters.getters_TOTAL_MONEY;
  }
  // 总数量
    get x_getters_TOTAL_number(): number {
    return this.$store.getters.getters_TOTAL_number;
  }

  looktotal(): void {
    console.log(this.x_getters_TOTAL_MONEY);
  }
  mounted(){
    console.log(this);
    
  }
}
</script>

<style scoped lang="scss">
.shopcar {
  position: fixed;
  bottom: 15px;
  width: 96%;
  margin-left: 2%;
  height: 60px;
  display: flex;
  border-radius: 60px;
  overflow: hidden;
  z-index: 9999;
  .left {
    width: 20%;
    background: #222;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #888;
  }
  .middle {
    display: flex;
    flex: 1;
    margin-left: 5px;
    background: #222;
    .middle-left {
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .van-icon__image {
      width: 50px;
      height: 50px;
    }
    .van-info {
      top: 10px;
      right: 15px;
    }
    .middle-right {
      display: flex;
      flex-direction: column;
      justify-content: center;
    }
  }
  .right {
    width: 20%;
    background: #ffc300;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
  }
}
.van-popup--bottom {
  padding-bottom: 90px;
}
.van-empty {
  padding-bottom: 100px;
}
</style>